package no.sachmuld.methodcombination.examples.reflection.fragilebaseclass;

import no.sachmuld.methodcombination.api.MethodInvocation;

import java.util.Collection;

/**
 *
 */
public class InstrumentedMethodCombinationHashSet<E> extends MethodCombinationHashSet<E> {

    private int addCount = 0;

    public InstrumentedMethodCombinationHashSet() {

        with(new HashSetBehaviour<E>() {

            @Override
            public boolean add(E e, MethodInvocation<Boolean> methodInvocation) {
                addCount++;
                return methodInvocation.proceed();
            }

            @Override
            public boolean addAll(Collection<? extends E> c, MethodInvocation<Boolean> methodInvocation) {
                addCount += c.size();
                return methodInvocation.proceed();
            }
        });
    }

    final public int getAddCount() {
        return addCount;
    }
}
